﻿//----------------------------------------------------------------------
// <copyright file="EntitySourceOperator.cs" company="NTT DATA BEEN (China)">
// Copyright (c)2012 NTT DATA BEEN (China) Information Technology Co.,Ltd.
// </copyright>
// <author> lidawei </author>
// <summary>
// システム名称　　：
// モジュールＩＤ　：
// モジュール名称　：
// 機能概要　　　　：EntitySourceOperator类 
// 改訂履歴　　　　：
// 2012-08-01 新規 lidawei    Been0001   
// </summary>
//---------------------------------------------------------------------- 
namespace Ntt.NttData.Been.Management.SolutionA.Sync.Operator.Model
{
    using System;
    using BLL;
    using Common.Data;

    public class EntitySourceOperator
    {
        public string OperatorId { get; set; }
        public string OperatorPass { get; set; }
        public string OperatorName { get; set; }
        public string OperatorNamekana { get; set; }
        public DateTime UpadteTime { get; set; }
        public JobRank Rank { get; set; }
        public string CaseId { get; set; }

        /// <summary>
        /// 权限格式转换
        /// Ma3.0 -> Ma1.9
        /// Customs the convert.
        /// </summary>
        /// <returns></returns>
       public  EntityOperator Convert()
       {  
          int eRankId;

          //转换
          var gender = JobRankTranslator.ToEntryLevel(Rank, out eRankId);
            
          if (gender == -1)
          {
              ShowMessage.Show("Rank转换失败",string.Format("opid:{0},rank:{1}",OperatorId,(int)Rank));

              var newRank = Rank.ChangeJobRank();
              // try again
              gender = JobRankTranslator.ToEntryLevel(newRank, out eRankId);

              ShowMessage.Show(gender == -1 ? "newRank转换失败" : "newRank转换成功",
                                   string.Format("opid:{0},newRank:{1}", OperatorId, (int) newRank));
          }

        return  new EntityOperator
            {
                OperatorNo = OperatorId,
                OperatorPass = OperatorPass,
                OperatorName = OperatorName,
                OperatorNameKana = OperatorNamekana,
                OperatorGender = gender,
                ERankId = eRankId,
                UpdateTime = UpadteTime
            };
       }

       
    }
}
